/**
 * 
 */
define([], function() {
	var FileLoader=function(params){
		var listView=params.listView;
		$.getJSON(ctx+"/attachmentAction/loadByAttSetId.do",{setId:params.attSetId},function(ds){
			$.each(ds,function(i,n){
				var iconPath=n.storageAddress;
				var extImp=getFileExtImg(n.originalFileName);
				iconPath=extImp?extImp:iconPath;
				var dom=
					'<div id="' + n.id + '" class="item">' +
					'<div class="imgDom">'+
					'<img src="'+root+iconPath+'">'+
					'</div>'+
					'<div class="desr">'+
                    '<div class="title">' + n.originalFileName +'</div>'+
                    '<div class="optBtns">'+
                    (params.readOnly?'':'&nbsp;&nbsp;<a href="javascript:void(0)" class="delBtn" onclick="webUtils.delFile(\''+n.id+'\',\''+n.id+'\')"><i class="glyphicon glyphicon-remove"/>删除</a>')+
                    '&nbsp;&nbsp;<a href="javascript:void(0)" onclick="webUtils.downloadFile(\''+n.id+'\')"><i class="glyphicon glyphicon-save"/>下载</a>'+
                    '</div>'+
                    '</div>'+
                    '<div style="clear: both;"/>'+
					'</div>';
				listView.append(dom);
			});
		});
	}
	var getFileExtImg=function(originalFileName){
		var imgMap={
			doc:"/res/images/fileType/1176732.png",
			docx:"/res/images/fileType/1176733.png",
			xls:"/res/images/fileType/1176750.png",
			xlsx:"/res/images/fileType/1176751.png",
			ppt:"/res/images/fileType/1176743.png",
			pptx:"/res/images/fileType/1176744.png"
		}
		var ext=getFileExt(originalFileName);
		return imgMap[ext];
	}
	
	var getFileExt=function(originalFileName){
		return originalFileName.substring(originalFileName.lastIndexOf('.') + 1).toLowerCase();
	}
	
	return FileLoader;
});
